{% extends 'layout/manage.html' %}
{% load static %}
{% block title %}{% endblock %}

{% block css %}
    <style>
    .title{
        border-right: 1px solid gray;
        min-height: 600px;/* 最小高度，当高度超过600时，高度会按照内容高度来，不会溢出 */


    }
    .content{
        border-left: 1px solid gray;
        min-height: 400px;
        margin-left: -1px;
    }
    .panel-body{
        padding: 0;
    }
    .content-right{
        margin-top: 50px;
        text-align: center;
    }
    </style>
    <link rel="stylesheet" href="{% static 'plugins/editor.md-master/css/editormd.min.css' %}">
{% endblock %}

{% block content %}
    <div class="container-fluid">
        <div class="panel panel-default">
          <div class="panel-heading clearfix">
              <div class="pull-left">

                  <i class="fa fa-book"></i> wiki文档
              </div>
              <div class="pull-right">
                  <a href="" class="btn btn-success btn-xs">
                      <i class="fa fa-plus-circle"></i> 新建
                  </a>
              </div>

          </div>
          <div class="panel-body">
            <div class="row">
                <div class="col-xs-3 title">
                    文章标题
                </div>
                <div class="col-xs-9 content">
                    <form method="post">
                    {% csrf_token %}
                        {% for field in form %}
                         <div class="form-group">
                            <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                             {% if field.name == 'content' %}
                             <div id="editor">
                                {{ field }}
                             </div>
                             {% else %}
                                {{ field }}
                             {% endif %}

                            <span class="error_msg">{{ field.errors.0 }}</span>
                          </div>
                        {% endfor %}



                      <button type="submit" class="btn btn-primary">提 交</button>
                    </form>



                </div>
            </div>
          </div>
        </div>


    </div>
{% endblock %}

{% block js %}
    <script src="{% static 'plugins/editor.md-master/editormd.min.js' %}"></script>
    <script>

        $(function() {
            initEditorMd();
        });

        function initEditorMd() {
            var editor = editormd("editor", {
                // width: "100%",
                // height: "100%",
                height:500,
                // placeholder:'hhhhh',
                imageUpload:true,
                imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
                imageUploadURL: "{% url 'wiki_upload' request.tracer_obj.project.id %}",  //上传的图片保存到哪里去，目标路径

                path : "{% static 'plugins/editor.md-master/lib/' %}"//指定给mdeditor的静态文件寻找目录
            });
        }


    </script>

{% endblock %}

